package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.DividendDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.Dividend;
import org.sixtynine.stock.service.DividendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class DividendServiceImpl implements DividendService {

	@Autowired
	private DividendDao dividendDao;

	@Override
	public Dividend findById(int id) {
		return dividendDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveDividend(Dividend dividend) {
		dividendDao.saveDividend(dividend);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteDividend(int id) {
		Dividend dividend = dividendDao.findById(id);
		if (dividend != null) {
			dividendDao.delete(dividend);
		}
	}

	@Override
	public List<Dividend> findDividend(String name) {
		return dividendDao.findDividend(name);
	}

	@Override
	public List<Dividend> searchDividend(int companyId, Date fromDate,
			Date toDate) {
		return dividendDao.searchDividend(companyId, fromDate, toDate);
	}

	@Override
	public Page<Dividend> searchDividend(int companyId, Date fromDate,
			Date toDate, GridPramDTO gridPramDTO) {
		return dividendDao.searchDividend(companyId, fromDate, toDate,
				gridPramDTO);
	}

	@Override
	public List<Dividend> searchDividend(int companyId) {
		return dividendDao.searchDividend(companyId);
	}

}
